<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>课程列表信息页面</title>
<style type="text/css">
body {
	background-image: url(background2.jpg);
}
</style>
</head>

<body>
<?php
/*---------------------一、变量参数定义-------------------------------*/
$username = $_GET['username'];
//$username = "student1";
echo "尊敬的用户：".$username."<br>";
echo "The courses list as:<br>";

/*---------------------二、URL数据传递-------------------------------*/
//$url = 'http://172.30.5.116/api_moodle/api_login.php';
//$url ='api_courselist.php';
//$url = 'localhost/api_moodle/api_courselist.php';
$url = 'http://192.168.2.101/api_moodle/api_courselist.php';
$fields = array('username'=>urlencode($username));
$ch = curl_init() ; // 开启一个curl对话
curl_setopt($ch, CURLOPT_URL,$url); //把要对话的url地址设置好
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_exec($ch); //执行上面设置好的一个curl操作，把变量数据发送完后，返回的是获得post变量执行后的结果
$result = curl_multi_getcontent($ch);
curl_close($ch) ; //关闭curl对话
$result = htmlspecialchars_decode($result); 
json_decode($result,1);

/*---------------------三、数据整理-------------------------------*/
//var_dump($result);
print_r($result);
?>
</body>
</html>
